package name.pilgr.soaboard.view;

import name.pilgr.soaboard.SoaboardApplication;

//import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

/**
 * Represents header of main page of application. 
 * @author masny
 *
 */
@SuppressWarnings("serial")
public class Header extends HorizontalLayout{
	//private static final ThemeResource ICON = new ThemeResource("../contacts/icons/32/reload.png");
	
	Label descrLbl;
	public Button refreshBtn, changeThemeBtn;
	Link h2ConsoleLink;
	
	
	public Header() {
		setSpacing(true);
		this.setSizeFull();
		descrLbl = new Label("<h3>SoaBoard</h3> " +
				             "Open source software for monitoring your SOA ");
		descrLbl.setContentMode(Label.CONTENT_XHTML);
		
		refreshBtn = new Button("Refresh now", new ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				SoaboardApplication.getProject().getUiHandler().refreshAll();			
			}
		});
		refreshBtn.setStyleName(Button.STYLE_LINK);
		//refreshBtn.setIcon(ICON);
		
		changeThemeBtn = new Button("Change theme", new ClickListener() {
			
			public void buttonClick(ClickEvent event) {
				SoaboardApplication.getProject().setTheme("runo");				
			}
		});
		changeThemeBtn.setStyleName(Button.STYLE_LINK);	
		
		h2ConsoleLink = new Link("H2 console",
	                new ExternalResource("console"));
		h2ConsoleLink.setDescription("Web console to internal H2 database");
	      
		
		
		this.addComponent(descrLbl);
		this.addComponent(refreshBtn);
		this.addComponent(changeThemeBtn);
		this.addComponent(h2ConsoleLink);
		
		this.setComponentAlignment(refreshBtn, Alignment.BOTTOM_RIGHT);
		this.setComponentAlignment(changeThemeBtn, Alignment.BOTTOM_RIGHT);
		this.setComponentAlignment(h2ConsoleLink, Alignment.BOTTOM_RIGHT);
	}


}
